//package com.huanletao.word;
//
//
//import com.lowagie.text.pdf.BaseFont;
//import fr.opensagres.xdocreport.itext.extension.font.IFontProvider;
//import org.apache.poi.xwpf.converter.pdf.PdfConverter;
//import org.apache.poi.xwpf.converter.pdf.PdfOptions;
//import org.apache.poi.xwpf.usermodel.XWPFDocument;
//
//import java.awt.*;
//import java.io.FileInputStream;
//import java.io.FileOutputStream;
//import java.io.IOException;
//
//public class demo1 {
//    public static void main(String[] args) throws IOException {
//        XWPFDocument doc = new XWPFDocument(new FileInputStream("替换为你的输出docx路径.docx");// docx
//        PdfOptions options = PdfOptions.create();
//// 中文字体处理
//        options.fontProvider(new IFontProvider() {
//
//            @Override
//            public com.lowagie.text.Font getFont(String familyName, String encoding, float size, int style, Color color) {
//                try {
//                    BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
//                    Font fontChinese = new Font(bfChinese, 12, style, color);
//                    if (familyName != null)
//                        fontChinese.setFamily(familyName);
//                    return fontChinese;
//                } catch (Exception e) {
//                    e.printStackTrace();
//                    return null;
//                }
//            }
//        });
//        PdfConverter.getInstance().convert(doc, new FileOutputStream("替换为你的输出pdf路径.pdf"), options);// pdf
//    }
//}
